package com.tuanbiao.models.action;

import androidx.annotation.NonNull;

import com.hzjq.data.callback.Callback;
import com.hzjq.data.entity.UIDRule;
import com.hzjq.data.entity.UIDRuleEntity;
import com.hzjq.lib.callback.OnUidSelectCallback;
import com.hzjq.lib.convert.chain.UIDChain;
import com.tuanbiao.data.callback.OnBaseResultCallback;

import java.util.List;

/**
 * @author abiao
 * @date 2022/7/28 10:17
 * @description:
 */
public interface ConfigAction {
    default void updateMillCode(UIDRuleEntity entity, OnBaseResultCallback<Boolean> callback) {
        UIDChain.Companion.onSelectUidRule(entity, new Callback<Boolean>() {
            @Override
            public void run(Boolean aBoolean) {
                callback.onSuccess(aBoolean);
                callback.onFinish();
            }
        });
    }

    default void queryMillCode(OnBaseResultCallback<UIDRuleEntity> callback) {
        UIDChain.Companion.getSelectUidRule(new OnUidSelectCallback() {
            @Override
            public void onUidSelectChanged(@NonNull UIDRuleEntity uidRuleEntity) {
                callback.onSuccess(uidRuleEntity);
            }
        });
    }

    default void getUidRule(UIDRule rule, OnBaseResultCallback<UIDRuleEntity> callback) {
        UIDChain.Companion.getUidRule(rule, new OnUidSelectCallback() {
            @Override
            public void onUidSelectChanged(@NonNull UIDRuleEntity uidRuleEntity) {
                callback.onSuccess(uidRuleEntity);
                callback.onFinish();
            }
        });

    }

    default void queryRules(OnBaseResultCallback<List<UIDRuleEntity>> callback) {
        UIDChain.Companion.queryRules(new Callback<List<UIDRuleEntity>>() {
            @Override
            public void run(List<UIDRuleEntity> uidRuleEntities) {
                callback.onSuccess(uidRuleEntities);
                callback.onFinish();
            }
        });
    }
}
